package com.rongdong.parkingcapture.controller;

import com.rongdong.parkingcapture.client.KafkaProducer;
import com.rongdong.parkingcapture.domain.Task;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Kafka控制层
 */
@RestController
public class KafkaController {

    @Resource
    private KafkaProducer kafkaProducer;

    @Value("${spring.kafka.topic}")
    private String topicName;

    /**
     * 生产消息
     */
    @GetMapping("/send")
    public void sendMsg(@RequestBody Task task){
        kafkaProducer.sendMessage(topicName, task);
    }

}
